<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 * @author   howe <howe1995@163.com>
 */
use Hyperf\Database\Migrations\Migration;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Schema\Schema;

return new class() extends Migration {
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('red_packets', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('from_user')->default(0)->comment('红包发送者');
            $table->unsignedBigInteger('to_user')->default(0)->comment('红包接收者');
            $table->unsignedBigInteger('group_id')->default(0)->comment('红包所属群');
            $table->enum('type', ['normal', 'lucky', 'belong'])->default('normal')->comment('红包类型');
            $table->unsignedBigInteger('total')->comment('红包总数');
            $table->unsignedBigInteger('stock')->comment('红包库存');
            $table->unsignedBigInteger('money')->comment('红包金额');
            $table->string('remark', 50)->default('')->comment('红包备注');
            $table->timestamp('overdued_at')->nullable()->default(null)->comment('红包过期时间');
            $table->timestamp('created_at')->useCurrent()->comment('红包创建时间');
            $table->timestamp('updated_at')->useCurrent()->comment('红包更新时间');
            $table->comment('红包表');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('red_packets');
    }
};
